<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Socket传输设备列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <button type="button" class="layui-btn" onclick="getDevList(1)">设备列表</button>
                <button type="button" class="layui-btn layui-btn-normal" onclick="getDevList(2)">注册列表</button>
                <button type="button" class="layui-btn layui-btn-danger" onclick="getDevList(4)">未注册列表</button>
                <button type="button" class="layui-btn " onclick="getDevList(5)">钉钉客户端</button>
                <button type="button" class="layui-btn " onclick="getDevList(6)">WEB客户端</button>
                <button type="button" class="layui-btn layui-btn-normal" onclick="updateGlobaData()">更新设备</button>
                <!--<form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">用户姓名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">用户性别</label>
                            <div class="layui-input-inline">
                                <input type="text" name="sex" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">用户城市</label>
                            <div class="layui-input-inline">
                                <input type="text" name="city" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">用户职业</label>
                            <div class="layui-input-inline">
                                <input type="text" name="classify" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </form>-->
            </div>
        </fieldset>



        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <div>

            <input type="text"  id="devGId"/>
            <a class="layui-btn layui-btn-normal layui-btn-xs" onclick="updateDevConf()">更新</a>
            <a class="layui-btn layui-btn-normal layui-btn-xs" onclick="selectDevConf()">查询</a>
        </div>

        <!--
                <script type="text/html" id="currentTableBar">
                    <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
                    <a class="layui-btn layui-btn-xs layui-btn-danger data-count-update" lay-event="delete">删除</a>
                </script>-->

    </div>
</div>
<script src="lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script>

    function getDevList(type) {
        $.ajax({
            type: "POST", //提交方式
            url: "http://127.0.0.1:9903/getDevByType",//路径
            data: {
                "type": type
            },//数据，这里使用的是Json格式进行传输
            success: function (data) {//返回数据根据结果进行相应的处理

                if (data.result = "success") {

                    if (data.data != null) {
                        handerData(data.data);
                    } else {
                        layer.alert('暂无内容');
                    }


                } else {
                    layer.alert('请求失败');
                }
            }
        });

    }

    function updateGlobaData() {
        $.ajax({
            type: "POST", //提交方式
            url: "http://127.0.0.1:9903/updateGlobaData",//路径

            success: function (data) {//返回数据根据结果进行相应的处理

                if (data.result = "success") {

                    layer.alert('更新成功');

                } else {
                    layer.alert('请求失败');
                }
            }
        });

    }

    function updateDevConf() {
        var devGId = $("#devGId").val();
        $.ajax({
            type: "POST", //提交方式
            url: "http://127.0.0.1:9903/updateDevConf",//路径
            data:{
              devGId:devGId
            },
            success: function (data) {//返回数据根据结果进行相应的处理

                if (data.result = "success") {
                    layer.alert('更新成功');
                } else {
                    layer.alert('请求失败');
                }
            }
        });
    }
    function selectDevConf() {
        var devGId = $("#devGId").val();
        $.ajax({
            type: "POST", //提交方式
            url: "http://127.0.0.1:9903/selectDevConf",//路径
            data:{
              devGId:devGId
            },
            success: function (data) {//返回数据根据结果进行相应的处理

                if (data.result = "success") {

                   layer.alert(JSON.stringify(data.data));

                } else {
                    layer.alert('请求失败');
                }
            }
        });
    }

    function handerData(data) {
        layui.use('table', function () {
            var table = layui.table;

            //展示已知数据
            table.render({
                elem: '#currentTableId'
                , cols: [[ //标题栏
                    {field: 'id', title: 'ID', width: 80, width: 300, sort: true}
                    , {field: 'devGId', title: '设备编号', width: 300}
                    , {field: 'address', title: '设备地址', width: 300}
                    , {field: 'isBind', title: '是否绑定', width: 300}
                    , {field: '备注', title: '备注信息', minWidth: 160}
                    , {fixed: 'right', width: 150, align: 'center', toolbar: '#barDemo'}
                    /* ,{field: 'sex', title: '性别', width: 80}
                     ,{field: 'city', title: '城市', width: 100}
                     ,{field: 'experience', title: '积分', width: 80, sort: true}*/
                ]]
                , data: data
                //,skin: 'line' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [10, 20, 30]
                , limit: 10 //每页默认显示的数量
            });


        });
    }



</script>

</body>
</html>